#pragma once
#pragma once
#include <string>
#include "msgdef.h"
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include "base/base.h"
#include "serial_port.h"
#include "duilib/UIlib.h"
#include "tcp_client.h"
#include "lua_wraper.h"
#include "global.h"
#include <fstream>
#include "udp_libevent.h"
#include <istream>
#include "websocket_client.h"
#include "lua_bind.h"
#include "websocket_server.h"

class WebsocketServerForm :
	public ui::ChildBox,
	LuaBindInterface
{
public:
	WebsocketServerForm(ui::Window* hwnd,
		string url, WebsocketServer* server);
	~WebsocketServerForm();
	virtual void Init() override;
	LuaDelegate* LuaVM();
	void ShowDataInEdit(const char*) ;

private:
	ui::Label* m_label_1;
	ui::RichEdit* m_rich_edit_1;
	ui::RichEdit* m_rich_edit_2;
	ui::RichEdit* m_websocket_send_edit;
	ui::Button* m_btn_send_data;
	ui::Button* m_btn_save_lua;
	ui::Button* m_btn_close_form;
	ui::CheckBox* m_check_box_1;
	ui::CheckBox* m_check_box_2;
	ui::CheckBox* m_check_box_3;
	ui::CheckBox* m_check_box_4;

	std::string m_url;
	WebsocketServer* m_server;
	std::fstream mLuaFileRead;
	std::ofstream mLuaFileEdit;

	LuaDelegate* mLua;
	std::string mLuaScript;
	std::ifstream mLuaFile;

};

